require('./rem.js')
require('../styl/basic.styl')
require('./imgInit.js')

//动画帧
window.reqAnimationFrame = (function () {
    return window[Hammer.prefixed(window, 'requestAnimationFrame')] || function (callback) {
        window.setTimeout(callback(), 1000 / 60);
    }
})()
//页面加载完触发
window.onload=function(){
  $('.girlImg').css('transform', 'translate3d( 300%, 0, 0)')
  $('.girlImg').addClass('girlAnimate')
  $('.boyImg').addClass('boyAnimate')
  setTimeout(function(){
    $('.girlSayImg').css('display', 'block')
  }, 2000)
}

//禁止拖动时触发上拉下拉事件
function stopScrolling(event){
  event.preventDefault()
}
document.addEventListener('touchmove', stopScrolling, false)

//喜欢和没感觉按钮
var noFeelHm = new Hammer($(".noFeelImg").get(0))
var likeHm = new Hammer($(".likeImg").get(0))
window.tapLock = false
window.topItemIndex = 1

noFeelHm.on('tap', function(){
  if(tapLock) return
  tapLock = true
  var topItem = $(".centerFrame img.item").first()
  topItem.addClass('animate')
  topItem.css('transform', 'translate3d( -' + topItem.height() + 'px, ' + topItem.width()/2 + 'px, 0)')
  if(topItemIndex <= 10){
    $('.boyImg').css('transform', 'translate3d( ' + 39*topItemIndex + '%, 0, 0)')
    topItemIndex++  
  }
  if($(".centerFrame img.item").length == 1){
    showHeiHeiHei()
  }
  setTimeout(function(){
    topItem.remove()
    tapLock = false
  },700)
})

likeHm.on('tap', function(){
  if(tapLock) return
  tapLock = true
  var topItem = $(".centerFrame img.item").first()
  topItem.addClass('animate')
  topItem.css('transform', 'translate3d( ' + topItem.height() + 'px, ' + topItem.width()/2 + 'px, 0)')
  if(topItemIndex <= 10){
    $('.boyImg').css('transform', 'translate3d( ' + 39*topItemIndex + '%, 0, 0)')
    topItemIndex++  
  }
  if($(".centerFrame img.item").length == 1){
    showHeiHeiHei()
  }
  setTimeout(function(){
    topItem.remove()
    tapLock = false
  },700)
})

//最后触发
window.showHeiHeiHei = function(){
  setTimeout(function(){
    $('.leftHeiImg').css('display', 'block')
  }, 600)
  setTimeout(function(){
    $('.rightHeiImg').css('display', 'block')
  }, 1200)
  setTimeout(function(){
    $('.bigHeiImg').css('display', 'block')
  },1800)
  setTimeout(function(){
    $('.moneyImg').css('display', 'block')
  },2400)
}

require('./itemInit.js')
